<h2><?= $this->translate('Listing photos');?></h2>
<div class="grid_12 alpha omega"><?= $this->flashMessenger(); ?></div>
<div class="clearfix"></div>
<p><a href="<?= $this->url(array(), 'gallery_photo_create'); ?>"><?= $this->translate('Create a new photo');?></a></p>
<div class="grid_12 alpha omega">
	<table width="100%">
		<thead>
			<tr>
				<th><?= $this->translate('ID');?></th>
				<th><?= $this->translate('Name');?></th>
				<th><?= $this->translate('Thumbnail');?>
				<th><?= $this->translate('Published');?></th>
				<th><?= $this->translate('Actions');?></th>
			</tr>
		</thead>
		<tbody>
			<?php if($this->photos->count() > 0):?>
				<?php foreach ($this->photos as $photo):?>
					<tr>
						<td style="text-align:center;">
							<?= $photo->id;?>
						</td>
						<td style="text-align:center;">
							<?= $photo->Translation[$this->LANG]->name;?>
						</td>
						<td style="text-align:center;">
							<?= $this->ImageTag('/upload/media/pictures/gallery/small/' . $photo->photo, $photo->Translation[$this->LANG]->name);?>
						</td>
						<td style="text-align:center;">
							<a href="#" id="publish_<?= $photo->id;?>" class="publish_b">
								<?= $this->IconPublished($photo->published);?>
							</a>
						</td>
						<td style="text-align:center;">
							<a href="<?= $this->url(array('id' => $photo->id), 'gallery_photo_update');?>">
								<?= $this->translate('Edit');?>
							</a>&nbsp;|&nbsp;
							<a href="<?= $this->url(array('id' => $photo->id), 'gallery_photo_delete');?>" onclick="return confirm('<?= $this->translate('Are you sure?');?>');">
								<?= $this->translate('Delete');?>
							</a>
						</td>
					</tr>
				<?php endforeach;?>
			<?php else: ?>
				<tr>
					<td colspan="7">
						<?= $this->translate('No items photos');?>
					</td>
				</tr>
			<?php endif; ?>
		</tbody>
	</table>
	<div><?= $this->paginator;?></div>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		$(".publish_b").click(function(){
			var id_str = $(this).attr('id');
			var id = id_str.substr(8);
			$.post("<?= $this->url(array(),'gallery_photo_publish');?>",{"id":id},function(data){
				if(data) {
					$("#publish_" + id).html('<?= $this->IconPublished(1);?>');
				} else {
					$("#publish_" + id).html('<?= $this->IconPublished(0);?>');
				}
			});
		});
	});
</script>